package com.example.personordersystem.dao.impl;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.example.personordersystem.dao.ContrastDao;
import com.example.personordersystem.dbHelper.DBOpenHelper;

public class ContrastDaoImpl implements ContrastDao {

	private DBOpenHelper helper;
	private SQLiteDatabase db;

	public ContrastDaoImpl(Context context) {
		helper = new DBOpenHelper(context);
	}

	private void getWritable() {
		db = helper.getWritableDatabase();

	}

	@Override
	public String getName(String s) {
		getWritable();
		Cursor cursor = db.rawQuery(
				"select name from t_contrast where colunmname=?",
				new String[] { s });
		if (cursor.moveToNext()) {
			return cursor.getColumnName(0);
		}
		return null;
	}

}
